package com.example.demoweb.config;

import com.example.demoweb.enums.TimeType;
import com.fasterxml.jackson.core.JacksonException;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer;

import java.io.IOException;

/**
 * @author 赵恒
 * @date 2023/5/22
 */
public class TimeTypeDeserializer extends JsonDeserializer<TimeType> {
    @Override
    public TimeType deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException, JacksonException {
        String text = jsonParser.getText();
        return TimeType.valueOf(text);
    }
}
